$(document).ready(function(){
    var button = $('#photo1'), interval;
    var fileType = "pic",fileNum = "one"; 
    new AjaxUpload(button,{
        action: _URL_+"/uploadpic",
        name: 'userfile',
        onSubmit : function(file, ext){
            if(fileType == "pic")
            {
                if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)){
                    this.setData({
                        'info': '文件类型为图片'
                    });
                } else {
                    button.text('非图片类型文件，重新上传');
                    return false;               
                }
            } 
            button.text('文件上传中');

            if(fileNum == 'one')
                this.disable();
			 interval = window.setInterval(function(){
                var text = button.text();
                if (text.length < 14){
                    button.text(text + '.');                    
                } else {
                    button.text('文件上传中');             
                }
            }, 200);
        },
        onComplete: function(file, response){
			button.text('本地上传');
            window.clearInterval(interval);         
            this.enable();
            $('#notice').html('');
			//上传完成显示截图功能
        	$('#photo1').attr('src',_PUBLIC_+"/Uploads/Photo/"+response);     
            setTimeout(function(){
            $('#photo1').imgAreaSelect({ 
            	persistent: true, 
            	resizable: true  
            });            	
            },200);
        }
    });
	
});

$(document).ready(function(){
    var button = $('#photo2'), interval;
    var fileType = "pic",fileNum = "one"; 
    new AjaxUpload(button,{
        action: _URL_+"/uploadpic",
        name: 'userfile',
        onSubmit : function(file, ext){
            if(fileType == "pic")
            {
                if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)){
                    this.setData({
                        'info': '文件类型为图片'
                    });
                } else {
                    button.text('非图片类型文件，重新上传');
                    return false;               
                }
            } 
            button.text('文件上传中');

            if(fileNum == 'one')
                this.disable();
			 interval = window.setInterval(function(){
                var text = button.text();
                if (text.length < 14){
                    button.text(text + '.');                    
                } else {
                    button.text('文件上传中');             
                }
            }, 200);
        },
        onComplete: function(file, response){
			button.text('本地上传');
            window.clearInterval(interval);         
            this.enable();
            $('#notice').html('');
			//上传完成显示截图功能
        	$('#photo2').attr('src',_PUBLIC_+"/Uploads/Photo/"+response);     
            setTimeout(function(){
            $('#photo2').imgAreaSelect({ 
            	persistent: true, 
            	resizable: true  
            });            	
            },200);
        }
    });
	
});


$(document).ready(function(){
    var button = $('#photo3'), interval;
    var fileType = "pic",fileNum = "one"; 
    new AjaxUpload(button,{
        action: _URL_+"/uploadpic",
        name: 'userfile',
        onSubmit : function(file, ext){
            if(fileType == "pic")
            {
                if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)){
                    this.setData({
                        'info': '文件类型为图片'
                    });
                } else {
                    button.text('非图片类型文件，重新上传');
                    return false;               
                }
            } 
            button.text('文件上传中');

            if(fileNum == 'one')
                this.disable();
			 interval = window.setInterval(function(){
                var text = button.text();
                if (text.length < 14){
                    button.text(text + '.');                    
                } else {
                    button.text('文件上传中');             
                }
            }, 200);
        },
        onComplete: function(file, response){
			button.text('本地上传');
            window.clearInterval(interval);         
            this.enable();
            $('#notice').html('');
			//上传完成显示截图功能
        	$('#photo3').attr('src',_PUBLIC_+"/Uploads/Photo/"+response);     
            setTimeout(function(){
            $('#photo3').imgAreaSelect({ 
            	persistent: true, 
            	resizable: true  
            });            	
            },200);
        }
    });
	
});